<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<#include "../head.html">
		<title>库存管理</title>
		<script type="text/javascript">
		var queryForm,queryDialog,inputForm,inputDialog,grid;
		$(function(){
			queryForm = Rainbow.Form({
				  formId:"#queryForm"
				 ,lable:true
				 ,inputArray:[
					 {lable:"产品名称",name:"productName",type:"textbox",condition:"like"}
				  ]
				 ,queryForm:true
			});
			
			queryDialog = Rainbow.Dialog({
		  		  title:"查询条件"
				 ,dialogId:'#queryDialog'
				 ,form:queryForm
				 ,width: '80%'
			 	 ,height: '50%'
		 		 ,modal: false
			     ,closable:true
			 	 ,buttons:[{
						text:'确认',
						iconCls:'icon-ok',
						handler:function(){
							grid.load();
							queryDialog.dialog('close');
						}
					}]
			});
			
			inputForm = Rainbow.Form({
				  formId:"#inputForm"
				 ,lable:true
				 ,inputArray:[
					 			 {name:"id",type:"hidden"}
					 			,{lable:"产品名称",name:"productName",option:{required:true}}
					 			,{lable:"数量",name:"amount",type:"numberbox",option:{precision:0,value:1,required:true}}
							]
			 	 ,colNum:1
			 	 , lableWidth:"80px"
			});
			
			inputDialog = Rainbow.Dialog({
				  title:"入库单"
				 ,width:400
				 ,height:300
				 ,dialogId:'#inputDialog'
				 ,form:inputForm
				 ,serviceName:"stock/StockService"
				 ,methodName:"save"
				 ,callback:function(result){
					 grid.load();
				 }
			 });
			
			grid = Rainbow.Grid({
				  serviceName:"stock/StockService"
				 ,queryForm:queryForm
				// ,paths:["account"]
				 ,columns: 
						[[
							 {field:'id',title:'选择',checkbox:true}
							,{field:'productName',title:'产品名称',width:150}
							,{field:'amount',title:'数量',width:150}
							,{field:'checkNum',title:'检查次数',width:150}
							,{field:'jobParam',title:'Job参数',width:150}
					    ]]
				,onDblClickRow: function (index, row) {
					grid.datagrid('selectRow',index);
				 	grid.update(inputDialog,inputForm);
		     	}
			});
		});
		</script>
	</head>
	<body class="easyui-layout" data-options="fit:true">
		<div id="toolbar">
			<a href="#" class="easyui-linkbutton" iconCls="icon-add" onclick="grid.save(inputDialog);" plain="true">添加</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-edit" onclick="grid.update(inputDialog,inputForm);" plain="true">修改</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-remove" onclick="grid.delete();" plain="true">删除</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="grid.query(queryDialog);" plain="true">查询</a>
		</div>
		<div id="grid"></div>
		<div id="queryDialog">
			<div id="queryForm"></div>
		</div>
		<div id="inputDialog">
			<form id="inputForm"></form>
		</div>
	</body>
</html>